/***************************************************************************************************
 *
 * Project: ChinesePod
 *
 * Class: Definition
 *
 * File name: Definition.java
 *
 * Jul 23, 2007
 *
 **************************************************************************************************/

package com.eastmountain.chinese.db.flashcards.records;

import java.io.ByteArrayInputStream;
import java.sql.Blob;

import com.eastmountain.util.DisplayFormats;

abstract public class ChineseElementProperties
                      extends ChineseElementKey 
                      implements Comparable<ChineseElementProperties> {
    
    protected short  soundOrdering = 0;
    protected String lessonSection = "";
    protected String pinyin        = "";
    protected String english       = "";
    protected String fileName      = "";
    protected ByteArrayInputStream sound = null;  
    
    public static final int NUMBER_OF_FIELD_VALUES = 5;

    public static final String SIMPLIFIED_CHARACTER  = "S";
    public static final String TRADITIONAL_CHARACTER = "T";

    public static final String LESSON_SECTION_DIALOG                   = "D";
    public static final String LESSON_SECTION_VOCABULARY               = "VN";
    public static final String LESSON_SECTION_SUPPLEMENTARY_VOCABULARY = "VS";
    public static final String LESSON_SECTION_PROPER_NAMES_VOCABULARY  = "VP";
    public static final String LESSON_SECTION_SOUND_DRILLS             = "S";

    public static final String LESSON_SECTION_NA                       = "N";

    public ChineseElementProperties() {

    }

    public ChineseElementProperties( String chineseElement, String simplifiedTraditional,
                                     int lessonNumber, String level,
                                     String lessonSection,
                                     String pinyin, String english ) {

        super( chineseElement, simplifiedTraditional,
                lessonNumber, level );

        this.lessonSection  = lessonSection;
        this.pinyin         = pinyin;
        this.english        = english;

    }

    public ChineseElementProperties( String chineseElement, String simplifiedTraditional,
                                     int lessonNumber, String level,
                                     String lessonSection,
                                     String pinyin, String english,
                                     String fileName,
                                     ByteArrayInputStream sound ) {

        super( chineseElement, simplifiedTraditional,
               lessonNumber, level );

        this.lessonSection  = lessonSection;
        this.pinyin         = pinyin;
        this.english        = english;
        this.fileName       = fileName;
        this.sound          = sound;  

    }

    public short getSoundOrdering() {
        return soundOrdering;
    }

    public void setSoundOrdering( short soundOrdering ) {
        this.soundOrdering = soundOrdering;
    }
    
    public String getLessonSection() {

        return (lessonSection);

    }

    public void setLessonSection( String lessonSection ) {

        this.lessonSection = lessonSection;

    }

    public String getPinyin() {

        return pinyin;
    }

    public void setPinyin( String pinyin ) {

        this.pinyin = pinyin;
    }

    public String getEnglish() {

        return english;
    }

    public void setEnglish( String english ) {

        this.english = english;
    }

    public ByteArrayInputStream getSound() {
        return sound;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName( String fileName ) {
        this.fileName = fileName;
    }

    public void setSound( ByteArrayInputStream sound ) {
        this.sound = sound;
    }
    
    public int compareTo( ChineseElementProperties
                          chineseElementProperties ) {

        int result = 0;

        if ( lessonNumber < (chineseElementProperties).getLessonNumber() ) {

           result = -1;

        } else if ( lessonNumber > chineseElementProperties.getLessonNumber() ) {

            result = 1;

        }

        return( result );
 }

    @Override
    public String toString() {

        String superString = super.toString();

        String elementProperties

        =   superString
            + "\nChineseElement -"
            + "\nWord - Character: " + getChineseElement()
            + "\nin Hex:           " + DisplayFormats.stringToHex( chineseElement )
            + "\nLevel:            " + getLevel()
            + "\nLessonSection:    " + getLessonSection()
            + "\nPinYin:           " + getPinyin()
            + "\nEnglish:          " + getEnglish();

        return( elementProperties );

    }

}
